﻿using System.Collections.Generic;
using ASPItalia.ModelVirtualCasting.ObjectModel;

namespace ASPItalia.ModelVirtualCasting.Web.Models
{
    public class NewsDetailsViewModel
    {
        public News NewsDetail { get; set; }

        public NewsDetailsViewModel()
        {
        }
	}

	public static class NewsExtensions
	{
		/// <summary>
		/// Formatta l'URL di una news per migliorare la SEO.
		/// </summary>
		/// <param name="news"></param>
		/// <returns></returns>
		public static string GetSlug(this News news)
		{
			return news != null ? GetNewsSlug(news.NewsTitle) : string.Empty;
		}

		/// <summary>
		/// Formatta l'URL di una news per migliorare la SEO.
		/// </summary>
		/// <param name="news"></param>
		/// <returns></returns>
		public static string GetSlug(this NewsDTO news)
		{
			return news != null ? GetNewsSlug(news.NewsTitle) : string.Empty;
		}

		private static string GetNewsSlug(string news)
		{
			// potrebbe essere necessario rimuovere altri caratteri
			return news.Replace(" ", "-").Replace("!", string.Empty).Replace("?", string.Empty).Replace("#", "Sharp").Replace(";", string.Empty).Replace(",", string.Empty);
		}
	}
}